package com.zhuss.order.processor;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import com.zhuss.bean.bo.order.order.DeletePrepayBo;
import com.zhuss.bean.vo.order.order.DetailPrepayVo;
import com.zhuss.common.AbstractProcessor;
import com.zhuss.common.Processor;
import com.zhuss.exception.DzcxException;
import com.zhuss.order.db.dao.ext.PrepayDao;
import com.zhuss.order.db.entity.Prepay;

/**
 * @description: 预支付删除
 * @author: zhushanshuo
 * @create: Tue Jan 12 18:10:03 CST 2021
 **/
@Component("prepayDelete")
public class PrepayDelete extends AbstractProcessor<Object, DeletePrepayBo> implements Processor<Object, DeletePrepayBo> {

    @Autowired
    private PrepayDao prepayDao;
    
    @Autowired
	@Qualifier("prepayRead")
	private PrepayRead prepayRead;
    
    
    /**
     * 校验
     */
	@Override
    public void check(DeletePrepayBo bo) throws DzcxException {
		// TODO 删除 预支付 校验， 请补充
    }
    
    /**
     * 操作方法
     */
    @Override
    public Object process(DeletePrepayBo param) throws DzcxException {
    	Long prepayId = param.getPrepayId();
    	String name = ((DetailPrepayVo) prepayRead.detail(prepayId)).getOrderId() + "";
    	
    	Prepay record = new Prepay();
    	record.setPrepayId(prepayId);
    	record.setDeleted(param.getDeleted());
    	
    	record.setModifierId(param.getConcurrentUserId());
    	record.setModifier(param.getConcurrentUserName());
    	record.setModifyTime(new Date());
    	prepayDao.delete(record);
    	param.setName(name);
        return null;
    }
    
    /**
     * 操作日志
     */
	@Override
	public Object log(DeletePrepayBo param) throws DzcxException {
    	return null;
	}
}
